package com.wontube.smr.web.controller.video;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.wontube.client.extension.utils.StringUtils;
import com.wontube.client.modle.vo.PagenateInfo;
import com.wontube.client.remote.Remoting;
import com.wontube.smr.client.constants.SiteConstants;
import com.wontube.smr.client.model.po.Genre;
import com.wontube.smr.client.model.po.Movie;
import com.wontube.smr.client.model.vo.MovieItems;
import com.wontube.smr.web.client.IMovieWebHandler;
import com.wontube.smr.web.client.IWebHomeHandler;
import com.wontube.smr.web.client.model.bo.QueryItemParams;
import com.wontube.smr.web.utils.SmrCookieUtils;

/**
 * 电影控制器
 * 
 * @author hewc@wondershare.cn
 * 
 */
@Controller
public class MovieController {

	public final static String ALL = "all";
	//private final static String ID_MOVIEFONE = "mf";
	//private final static String ID_HULU = "hl";
	//private final static String ID_YOUTUBE = "yt";
	//private final static String ID_IMDB = "ib";
	private final static String SORT_TIME = "time";
	private final static int BOWSE_PAGE_SITE = 35;

	// private final static String WEBSITE_MOVIEFONE = "Moviefone";
	// private final static String WEBTYPE_MOVIE = "Movie";
	// private final static String WEBTYPE_TRAILER = "Trailer";
	
	@RequestMapping("/movie")
	public void movieHome0(HttpServletRequest request, 
			HttpServletResponse response) throws IOException{	
		response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
		response.sendRedirect(request.getContextPath() + "/movie/");	
	}

	/**
	 * 电影主页
	 * 
	 * @return
	 * @throws IOException 
	 */
	@RequestMapping("/movie/")
	public ModelAndView movieHome(HttpServletRequest request, 
			HttpServletResponse response) throws IOException {
		//判断是否跳转过来的链接
		String ref = request.getParameter("f");
		if( ! StringUtils.isNullOrEmpty(ref)){			
			SmrCookieUtils.setRefCookie(response, ref);
			
			//判断ip,是否需要跳到国际版
			if(isFromWorldWide()){
				response.sendRedirect(request.getContextPath() + "/world/movie/");
				return null;
			}
		}
		
		return movieNowPopular();
	}	

	private boolean isFromWorldWide() {
		Remoting<IWebHomeHandler> remoting = new Remoting<IWebHomeHandler>();
		IWebHomeHandler handler = remoting.createService(IWebHomeHandler.class);
		Boolean bool = handler.isFromWorldWide();
		return bool != null ? bool.booleanValue() : false; 
	}
	
	@RequestMapping("/movie/popular")
	public void m1(HttpServletRequest request, 
			HttpServletResponse response) throws IOException{	
		response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
		response.sendRedirect(request.getContextPath() + "/movie/popular/");	
	}

	/**
	 * now-popular 主页
	 * 
	 * @return
	 */
	@RequestMapping("/movie/popular/")
	public ModelAndView movieNowPopular() {
		ModelAndView mv = new ModelAndView("/video/movie/popular/popular_index");
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		Map<String, Object> map = handler.listMovieWebHome();
		mv.addAllObjects(map);		
		return mv;
	}

	/**
	 * now-popular 详情页
	 * 
	 * @param movieId
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/movie/popular/{id}")
	public ModelAndView movieNowPopularDeatail(@PathVariable("id") String movieId, HttpServletResponse response)
			throws IOException {
		IMovieWebHandler handler = getMovieHandler();
		Movie movie = handler.getMovie(movieId);							
		if (movie == null) {
			response.sendError(HttpServletResponse.SC_NOT_FOUND);
			return null;
		}
		ModelAndView mv = new ModelAndView("/video/movie/detail/detail_index");
		mv.addObject("show", movie);
		mv.addObject("category", "popular");
		return mv;
	}

	/**
	 * now-popular 播放器页
	 * 
	 * @param movieId
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/movie/popular/watch-{id}")
	public ModelAndView movieNowPopularPlay(@PathVariable("id") String movieId, HttpServletResponse response)
			throws IOException {		
		IMovieWebHandler handler = getMovieHandler();
		Movie movie = handler.getMovie(movieId);							
		if (movie == null) {
			response.sendError(HttpServletResponse.SC_NOT_FOUND);
		}
		ModelAndView mv = new ModelAndView();
		if(SiteConstants.WEBSITE_MOVIEFONE.equals(movie.getWebsite())){
			mv.setViewName("video/movie/play/moviefone_player");
		}else{
			mv.setViewName("video/movie/play/hulu_player");
		}
		
		mv.addObject("movie", movie);
		mv.addObject("category", "popular");
		
		return mv;
	}
	
	@RequestMapping("/movie/full-length")
	public void m2(HttpServletRequest request, 
			HttpServletResponse response) throws IOException{	
		response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
		response.sendRedirect(request.getContextPath() + "/movie/full-length/");	
	}

	/**
	 * full-length 主页
	 * 
	 * @param genre
	 * @param page
	 * @param sort
	 * @param decade
	 * @param initial
	 * @return
	 */
	@RequestMapping("/movie/full-length/")
	public ModelAndView movieFullLength(QueryItemParams params,
			@RequestParam(value = "page", required = false, defaultValue = "1") Integer page) {		
		IMovieWebHandler handler = getMovieHandler();			
		params.setNeedGenres(true);
		MovieItems items = handler.listFullLengthMovies(params, new PagenateInfo(page, BOWSE_PAGE_SITE));

		ModelAndView mv = new ModelAndView("/video/movie/full/movie_full_index");	
		mv.addObject("showItems", items);
		if (items != null) {
			mv.addObject("genres", items.getGenres());
			mv.addObject("category", "full-length");
		}
		
		mv.addObject("page", page);
		return mv;
	}
	
	@RequestMapping("/movie/full-lengths")
	public ModelAndView movieFullLengths() {
		ModelAndView mv = new ModelAndView("/video/movie/full/movie_full_index");		
		mv.addObject("genres",getMovieGenres());
		mv.addObject("category", "full-length");
		return mv;
	}
	/**
	 * full-length 详情页
	 * 
	 * @param movieId
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/movie/full-length/{id}")
	public ModelAndView movieFullLengthDeatail(@PathVariable("id") String movieId, HttpServletResponse response)
			throws IOException {
		IMovieWebHandler handler = getMovieHandler();
		Movie movie = handler.getMovie(movieId);							
		if (movie == null) {
			response.sendError(HttpServletResponse.SC_NOT_FOUND);
			return null;
		}
		
		ModelAndView mv = new ModelAndView("video/movie/detail/detail_index");
		mv.addObject("genres", getMovieGenres());		
		mv.addObject("show", movie);
		mv.addObject("category", "full-length");
		return mv;
	}

	/**
	 * full-length 播放页面
	 * 
	 * @param movieId
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/movie/full-length/watch-{id}")
	public ModelAndView movieFullLengthPlay(@PathVariable("id") String movieId, HttpServletResponse response)
			throws IOException {
		IMovieWebHandler handler = getMovieHandler();
		Movie movie = handler.getMovie(movieId);							
		if (movie == null) {
			response.sendError(HttpServletResponse.SC_NOT_FOUND);
			return null;
		}
		
		ModelAndView mv = new ModelAndView("video/movie/play/hulu_player");
		mv.addObject("movie", movie);
		mv.addObject("category", "full-length");
		return mv;
	}

	@RequestMapping("/movie/full-length/genre/{genre}")
	public ModelAndView movieFullLengthGenre(@PathVariable("genre") String genre, HttpServletResponse response)
			throws IOException {
		ModelAndView mv = getFullLengthViewWithGenres(genre, null, null, null);
		mv.addObject("genre",genre);
		return mv;
	}

	@RequestMapping("/movie/full-length/decade/{decade}")
	public ModelAndView movieFullLengthDecade(@PathVariable("decade") Integer decade, HttpServletResponse response)
			throws IOException {
		ModelAndView mv = getFullLengthViewWithGenres(null, null, decade, null);
		mv.addObject("decade",decade);
		return mv;
	}

	@RequestMapping("/movie/full-length/alpha/{alpha}")
	public ModelAndView movieFullLengthAlpha(@PathVariable("alpha") String initial, HttpServletResponse response)
			throws IOException {
		ModelAndView mv = getFullLengthViewWithGenres(null, initial, null, null);
		mv.addObject("alpha", initial);
		return mv;
	}

	@RequestMapping("/movie/full-length/page/{page}")
	public ModelAndView movieFullLengthAlpha(@PathVariable("page") Integer page, HttpServletResponse response)
			throws IOException {
		return getFullLengthViewWithGenres(null, null, null, page);
	}

	@RequestMapping("/movie/full-length/relate/{id}")
	public ModelAndView movieFullLengthrelate(@PathVariable("id") String id, HttpServletResponse response)
			throws IOException {
		ModelAndView mv = new ModelAndView("/video/movie/play/hulu_player_chrome");
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		QueryItemParams params = new QueryItemParams();
		MovieItems items = handler.listFullLengthMovies(params, new PagenateInfo(1, 6));
		List<Movie> list = new ArrayList<Movie>();
		for (Movie movie : items.getItems()) {
			if (!movie.getId().equals(id) && list.size() < 5) {
				list.add(movie);
			}
		}
		items.setItems(list);
		mv.addObject("showItems", items);		
		return mv;
	}

	private ModelAndView getFullLengthViewWithGenres(String genre, String initial, Integer decade, Integer page) {
		ModelAndView mv = new ModelAndView("/video/movie/full/movie_full_index");
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		QueryItemParams params = new QueryItemParams();
		params.setGenre(genre);
		params.setInitial(initial);
		params.setDecade(decade);
		params.setNeedGenres(true);
		if (page == null) {
			page = 1;
		}

		MovieItems items = handler.listFullLengthMovies(params, new PagenateInfo(page, BOWSE_PAGE_SITE));

		mv.addObject("showItems", items);
		if (items != null) {
			mv.addObject("genres", items.getGenres());
			mv.addObject("category", "full-length");
		}
		mv.addObject("page", page);
		return mv;
	}


	@RequestMapping("/movie/full-length/query")
	public ModelAndView query(QueryItemParams params,
			@RequestParam(value = "page", required = false, defaultValue = "1") Integer page) {

		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		params.setNeedGenres(false);
		MovieItems items = handler.listFullLengthMovies(params, new PagenateInfo(page, BOWSE_PAGE_SITE));
		ModelAndView mv = new ModelAndView("/video/movie/full/movie_full_list");
		mv.addObject("showItems", items);
		mv.addObject("queryInitial", params.getInitial());
		mv.addObject("sort", params.getSort());
		return mv;
	}

	@RequestMapping("/movie/full-length/scroll")
	public ModelAndView queryScroll(QueryItemParams params,
			@RequestParam(value = "page", required = false, defaultValue = "1") Integer page) {

		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		params.setNeedGenres(false);
		MovieItems items = handler.listFullLengthMovies(params, new PagenateInfo(page, BOWSE_PAGE_SITE));
		ModelAndView mv = new ModelAndView("/video/movie/full/movie_full_list");
		mv.addObject("showItems", items);		
		return mv;
	}
	
	@RequestMapping("/movie/movie2012")
	public void m3(HttpServletRequest request, 
			HttpServletResponse response) throws IOException{	
		response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
		response.sendRedirect(request.getContextPath() + "/movie/movie2012/");	
	}


	/**
	 * movie 2012 主页面
	 * 
	 * @return
	 */
	@RequestMapping("/movie/movie2012/")
	public ModelAndView getTrailers(@RequestParam(value = "month", required = false, defaultValue = "0") Integer month) {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/video/movie/year/movie_year_index");		
		IMovieWebHandler handler = getMovieHandler();
		PagenateInfo pageInfo = new PagenateInfo();
		pageInfo.setPageNo(1);
		pageInfo.setPageSize(40);
		Calendar cal = Calendar.getInstance();		
		int year = cal.get(Calendar.YEAR);		
		if (month == 0) {
			month = cal.get(Calendar.MONTH) + 1;
		}
		
		MovieItems items = handler.listThisYearTraillers(year, month, pageInfo);		
		mv.addObject("showItems", items);
		mv.addObject("month", month);
		mv.addObject("year", String.valueOf(year));
		//mv.addObject("page", 1);
		return mv;
	}

	/**
	 * movie 2012 详情页
	 * 
	 * @param movieId
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/movie/movie2012/{id}")
	public ModelAndView movieThisYearDetail(@PathVariable("id") String movieId, HttpServletResponse response)
			throws IOException {
		IMovieWebHandler handler = getMovieHandler();
		Movie movie = handler.getMovie(movieId);							
		if (movie == null) {
			response.sendError(HttpServletResponse.SC_NOT_FOUND);
			return null;
		}
		
		ModelAndView mv = new ModelAndView("/video/movie/detail/detail_index");
		mv.addObject("show", movie);
		mv.addObject("category", "movie2012");
		return mv;
	}

	/**
	 * movie 2012 播放页面
	 * 
	 * @param movieId
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/movie/movie2012/watch-{id}")
	public ModelAndView movieThisYearPlay(@PathVariable("id") String movieId, HttpServletResponse response)
			throws IOException {
		IMovieWebHandler handler = getMovieHandler();
		Movie movie = handler.getMovie(movieId);							
		if (movie == null) {
			response.sendError(HttpServletResponse.SC_NOT_FOUND);
			return null;
		}
		
		ModelAndView mv = new ModelAndView("/video/movie/play/moviefone_player");
				
		mv.addObject("movie", movie);
		mv.addObject("category", "movie2012");
		return mv;
	}

	@RequestMapping("/movie/movie2012/month/{month}")
	public ModelAndView this_year_month(@PathVariable("month") Integer month) {
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		Calendar cal = Calendar.getInstance();
		Integer year = cal.get(Calendar.YEAR);
		if (month == null || month == 0) {
			month = cal.get(Calendar.MONTH) + 1;
		}
		Integer page = 1;
		MovieItems items = handler.listThisYearTraillers(year, month, new PagenateInfo(page, BOWSE_PAGE_SITE));
		ModelAndView mv = new ModelAndView("/video/movie/year/movie_year_index");
		mv.addObject("showItems", items);
		//mv.addObject("genres", getMovieGenres());
		mv.addObject("page", page);
		mv.addObject("month", month);
		mv.addObject("year", year);
		return mv;
	}

	@RequestMapping("/movie/movie2012/query")
	public ModelAndView this_year_query(@RequestParam(value = "year", required = false) Integer year,
			@RequestParam(value = "month", required = false) Integer month,
			@RequestParam(value = "page", required = false, defaultValue = "1") Integer page) {
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		Calendar cal = Calendar.getInstance();
		if (year == null || year == 0) {
			year = cal.get(Calendar.YEAR);
		}
		if (month == null || month == 0) {
			month = cal.get(Calendar.MONTH) + 1;
		}
		MovieItems items = handler.listThisYearTraillers(year, month, new PagenateInfo(page, BOWSE_PAGE_SITE));
		ModelAndView mv = new ModelAndView("/video/movie/year/movie_year_main");
		mv.addObject("showItems", items);
		// mv.addObject("genres", getGenres());
		mv.addObject("page", page);
		mv.addObject("month", month);
		mv.addObject("year", year);
		return mv;
	}
	
	@RequestMapping("/movie/trailer")
	public void m4(HttpServletRequest request, 
			HttpServletResponse response) throws IOException{	
		response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
		response.sendRedirect(request.getContextPath() + "/movie/trailer/");	
	}

	/**
	 * trailers 主页面
	 * 
	 * @return
	 */
	@RequestMapping("/movie/trailer/")
	public ModelAndView getMovieTrailers() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/video/movie/trailer/trailers_index");
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		PagenateInfo pageInfo = new PagenateInfo();
		pageInfo.setPageNo(1);
		pageInfo.setPageSize(BOWSE_PAGE_SITE);
		QueryItemParams params = new QueryItemParams();
		params.setNeedGenres(true);
		params.setSort(SORT_TIME);
		MovieItems items = handler.listMovieTraillers(params, new PagenateInfo(1, BOWSE_PAGE_SITE));
		if (items != null) {
			mv.addObject("genres", items.getGenres());
			mv.addObject("category", "trailer");
		}

		mv.addObject("showItems", items);
		mv.addObject("page", 1);
		return mv;
	}
	
	@RequestMapping(value = "/movie/trailers")
	public ModelAndView getMovieTrailerss(){
		ModelAndView mv = new ModelAndView("/video/movie/trailer/trailers_index");		
		mv.addObject("genres",getMovieTrailerGenres());
		mv.addObject("category", "trailer");
		return mv;
	}
	
	/**
	 * trailers 明细页面
	 * 
	 * @param movieId
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/movie/trailer/{id}")
	public ModelAndView movieTrailersDetail(@PathVariable("id") String movieId, HttpServletResponse response)
			throws IOException {
		IMovieWebHandler handler = getMovieHandler();
		Movie movie = handler.getMovie(movieId);							
		if (movie == null) {
			response.sendError(HttpServletResponse.SC_NOT_FOUND);
			return null;
		}
		
		ModelAndView mv = new ModelAndView("/video/movie/detail/detail_index");
		mv.addObject("genres", getMovieTrailerGenres());		
		mv.addObject("show", movie);
		mv.addObject("category", "trailer");
		return mv;
	}

	/**
	 * Trailers 播放页面
	 * 
	 * @param movieId
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping("/movie/trailer/watch-{id}")
	public ModelAndView movieTrailersPlay(@PathVariable("id") String movieId, HttpServletResponse response)
			throws IOException {
		IMovieWebHandler handler = getMovieHandler();
		Movie movie = handler.getMovie(movieId);							
		if (movie == null) {
			response.sendError(HttpServletResponse.SC_NOT_FOUND);
			return null;
		}
		
		ModelAndView mv = new ModelAndView();
		if(SiteConstants.WEBSITE_IMDB.equals(movie.getWebsite())){
			mv.setViewName("video/movie/play/imdb_player");
		}else{
			mv.setViewName("video/movie/play/moviefone_player");
		}		
				
		mv.addObject("movie", movie);
		mv.addObject("genres", getMovieGenres());		
		mv.addObject("category", "trailer");
		return mv;
	}

	@RequestMapping("/movie/trailer/genre/{genre}")
	public ModelAndView movieTrailersGenre(@PathVariable("genre") String genre, HttpServletResponse response,
			@RequestParam(value = "page", required = false, defaultValue = "1") Integer page) throws IOException {
		ModelAndView mv = getTrailerViewWithGenres(genre, null, null, page);
		mv.addObject("genre",genre);
		return mv;
	}

	@RequestMapping("/movie/trailer/decade/{decade}")
	public ModelAndView movieTrailersDecade(@PathVariable("decade") Integer decade, HttpServletResponse response,
			@RequestParam(value = "page", required = false, defaultValue = "1") Integer page) throws IOException {
		ModelAndView mv = getTrailerViewWithGenres(null, null, decade, page);
		mv.addObject("decade",decade);
		return mv;
	}

	@RequestMapping("/movie/trailer/alpha/{alpha}")
	public ModelAndView movieTrailersAlpha(@PathVariable("alpha") String initial, HttpServletResponse response,
			@RequestParam(value = "page", required = false, defaultValue = "1") Integer page) throws IOException {
		ModelAndView mv = getTrailerViewWithGenres(null, initial, null, page);
		mv.addObject("alpha",initial);
		return mv;
	}

	private ModelAndView getTrailerViewWithGenres(String genre, String initial, Integer decade, Integer page) {
		ModelAndView mv = new ModelAndView("/video/movie/trailer/trailers_index");
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		QueryItemParams params = new QueryItemParams();
		params.setGenre(genre);
		params.setInitial(initial);
		params.setDecade(decade);
		params.setNeedGenres(true);
		if (page == null) {
			page = 1;
		}

		MovieItems items = handler.listMovieTraillers(params, new PagenateInfo(page, BOWSE_PAGE_SITE));

		mv.addObject("showItems", items);
		if (items != null) {
			mv.addObject("genres", items.getGenres());
		}
		mv.addObject("page", page);
		mv.addObject("genre", genre);
		mv.addObject("decade", decade);
		mv.addObject("category", "trailer");
		return mv;
	}

	@RequestMapping("/movie/trailer/query")
	public ModelAndView trailers_query(QueryItemParams params,
			@RequestParam(value = "page", required = false, defaultValue = "1") Integer page) {
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);

		params.setNeedGenres(false);
		params.setSort(SORT_TIME);
		MovieItems items = handler.listMovieTraillers(params, new PagenateInfo(page, BOWSE_PAGE_SITE));
		ModelAndView mv = new ModelAndView("/video/movie/trailer/trailer_main_list");
		mv.addObject("showItems", items);
		
		return mv;
	}

	@RequestMapping("/movie/trailers/relate")
	public ModelAndView relate_trailers() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/video/movie/play/moviefone_relate");
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		QueryItemParams params = new QueryItemParams();
		params.setNeedGenres(false);
		params.setSort(SORT_TIME);
		MovieItems items = handler.listMovieTraillers(params, new PagenateInfo(1, 5));
		mv.addObject("showItems", items);
		mv.addObject("page", 1);
		return mv;
	}

	/**
	 * 组积流派信息
	 * 
	 * @return
	 */
	private List<Genre> getMovieGenres() {
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		return handler.listMovieGenres();
	}
	
	private List<Genre> getMovieTrailerGenres() {
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		IMovieWebHandler handler = remoting.createService(IMovieWebHandler.class);
		return handler.listMovieTrailerGenres();
	}
	
	private IMovieWebHandler getMovieHandler(){
		Remoting<IMovieWebHandler> remoting = new Remoting<IMovieWebHandler>();
		return remoting.createService(IMovieWebHandler.class);
	}
}